package com.example.delivery.exception;

import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.servlet.ModelAndView;

@ControllerAdvice
public class GlobalExceptionHandler {
    
    @ExceptionHandler(Exception.class)
    public String handleAllExceptions(Exception e, Model model) {
        // 将异常信息添加到 Model 中
        model.addAttribute("errorMessage", e.getMessage());
        model.addAttribute("stackTrace", e.getStackTrace());
         System.out.println("======================" + e.getMessage() + "======================");
         return "error";
    }
}